<?php

try {

	// // 链接数据库
	$link = @new PDO("mysql:host=127.0.0.1;dbname=school;charset=utf8","root","root");

	// 组预准备语句
	$sql = "insert into stu (sname,age,sex) values(:sname,:age,:sex)";

	$stmp = $link->prepare($sql);

	$stmp->bindParam(':sname', $sname, PDO::PARAM_STR,20);
	$stmp->bindParam(':age', $age, PDO::PARAM_INT, 2);
	$stmp->bindParam(':sex', $sex, PDO::PARAM_STR, 2);

	$sname = "小马";
	$age = 20;
	$sex= "男";

	$res = $stmp->execute();

	var_dump($res);
	
} catch (Exception $e) {
	// echo($e->getMessage());
	echo("系统异常");
}